package com.ruoyi.data.service.impl;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.data.domain.DataGold;
import com.ruoyi.data.mapper.DataGoldMapper;
import com.ruoyi.data.service.IDataGoldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 金豆记录Service业务层处理
 *
 * @author zzp
 * @date 2022-09-30
 */
@Service
public class DataGoldServiceImpl implements IDataGoldService {
    @Autowired
    private DataGoldMapper dataGoldMapper;

    /**
     * 查询金豆记录
     *
     * @param id 金豆记录主键
     * @return 金豆记录
     */
    @Override
    public DataGold selectDataGoldById(Long id) {
        return dataGoldMapper.selectDataGoldById(id);
    }

    /**
     * 查询金豆记录列表
     *
     * @param dataGold 金豆记录
     * @return 金豆记录
     */
    @Override
    @DataScope(deptAlias = "d")
    public List<DataGold> selectDataGoldList(DataGold dataGold) {
        return dataGoldMapper.selectDataGoldList(dataGold);
    }

    /**
     * 新增金豆记录
     *
     * @param dataGold 金豆记录
     * @return 结果
     */
    @Override
    public int insertDataGold(DataGold dataGold) {
        dataGold.setCreateTime(DateUtils.getNowDate());
        return dataGoldMapper.insertDataGold(dataGold);
    }

    /**
     * 修改金豆记录
     *
     * @param dataGold 金豆记录
     * @return 结果
     */
    @Override
    public int updateDataGold(DataGold dataGold) {
        dataGold.setUpdateTime(DateUtils.getNowDate());
        return dataGoldMapper.updateDataGold(dataGold);
    }

    /**
     * 批量删除金豆记录
     *
     * @param ids 需要删除的金豆记录主键
     * @return 结果
     */
    @Override
    public int deleteDataGoldByIds(Long[] ids) {
        return dataGoldMapper.deleteDataGoldByIds(ids);
    }

    /**
     * 删除金豆记录信息
     *
     * @param id 金豆记录主键
     * @return 结果
     */
    @Override
    public int deleteDataGoldById(Long id) {
        return dataGoldMapper.deleteDataGoldById(id);
    }

    @Override
    public List<DataGold> selectDataGoldListByUserId(Long userId, String goldType) {
        return dataGoldMapper.selectDataGoldListByUserId(userId, goldType);
    }
}
